# -*- coding: utf-8 -*-
# @Time    : 2019/11/2 16:13
# @Author  : LiHaowen
# @Email   : lihaowen2017@163.com
# @File    : gen_throw.py


def gen_func():
    try:
        html = yield "http://projectsedu.com"
    except Exception as e:  # 处理throw传递进来的异常
        pass

    # print(html)
    yield 2
    yield 3
    return "b1"


if __name__ == '__main__':
    gen = gen_func()
    print(next(gen))
    gen.throw(Exception, "download error")  # 往生成器中添加指定异常
    print(next(gen))
    gen.throw(Exception, "download error")